<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=j, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const reg = /[?？]/
            //正则替换
        let a = prompt('请输入需要填写的值')
            // alert(a.replace(reg, '*'))
            //正则匹配
            // alert(reg.test(a))
            //正则提取。
        alert(a.match(reg))
    </script>
</body>

</html>